// 此文件是我自己封装的ajax请求模块，里面存放了项目所有的 ajax 请求

// 局部导入 axios
import axios from "axios"





// 定义基础路径
const baseUrl = "/altmanApi/" // 开发环境的代理路径
// const baseUrl =  'http://localhost:1024/api' // 生产环境的原始路径


// 封装一个通用的ajax请求函数
function ajax_get(path, params = {}) {
    return axios.get(baseUrl + path, { params })
}




// 1.请求轮播图
let getBanner = ()=> ajax_get('banner');


// 2.请求商品列表
let getGoodList = params => ajax_get('goodList', params);

// 3.登录请求
let getLogin = params => ajax_get('login', params)

// 4.请求标题
let getTypeOnes  = ()=> ajax_get('getTypeOne')

// 5.注册
let getRegister = params => ajax_get("register",params);

// 6.搜索
let getSearch = params => ajax_get("search",params);

// 7.商品详情
let getDetail = params => ajax_get("detail",params);

// 8. 同店相似商品推荐
var getSameGoods = params => ajax_get("sameList", params)

// 9. 获取购物车数据
var getCartList = params => ajax_get("shopList", params)

// 10.  添加购物车/数量
let getCartAdd = params => ajax_get("add",params);

// 11. 购物车商品数量减小
var getCartRemove = params => ajax_get("remove", params)

// 12.删除购物车商品
var getCartDelete = params => ajax_get("del", params)

// 导出所有函数
export { 
    getBanner, 
    getGoodList, 
    getLogin,
    getTypeOnes, 
    getRegister,
    getSearch,
    getDetail,
    getSameGoods,
    getCartList,
    getCartAdd,
    getCartRemove,
    getCartDelete,
};

